//
//  VCMyViewController.m
//  VCShop
//
//  Created by VoyageCN on 16/8/17.
//  Copyright © 2016年 VoyageCN. All rights reserved.
//

#import "VCMyViewController.h"
#import "VCMyTableView.h"
#import "VCMyTableViewCell.h"
#import "VCMyHeaderView.h"
#import "VCRegisterViewController.h"
#import "VCLoginViewController.h"


@interface VCMyViewController ()

@property (nonatomic, strong) VCMyHeaderView *headerView;

@property (nonatomic, strong) VCMyTableView *tableView;

@end

@implementation VCMyViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.view.backgroundColor = MainColor;
    self.edgesForExtendedLayout = 0;

    [self.view addSubview:self.headerView];
    [self.view addSubview:self.tableView];
    
    __weak typeof (self) weakSelf = self;
    
    [_headerView mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.top.left.right.equalTo(weakSelf.view);
        make.height.equalTo(@150);
    }];
        
    [_tableView mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.left.right.equalTo(weakSelf.view);
        make.height.equalTo(@176);
        make.top.equalTo(weakSelf.headerView.mas_bottom).offset(35);
    }];
    
    
}

- (VCMyHeaderView *)headerView {
    
    if (!_headerView) {
        _headerView = [[VCMyHeaderView alloc] init];
        __weak typeof (self) weakSelf = self;
        _headerView.registerBlock = ^(){
            VCLog(@"我点击了注册按钮");
            VCRegisterViewController* registerView = [[VCRegisterViewController alloc]init];
            [weakSelf.navigationController pushViewController:registerView animated:YES];
        };
        _headerView.loginBlock = ^(){
            VCLog(@"我点击了登录按钮");
            VCLoginViewController *loginView = [[VCLoginViewController alloc] init];
            [weakSelf.navigationController pushViewController:loginView animated:YES];
        };
    }
    return _headerView;
}

- (VCMyTableView *)tableView {
    
    if (!_tableView) {
        _tableView = [[VCMyTableView alloc] initWithFrame:CGRectMake(0, 0, 0, 0) style:UITableViewStylePlain];
    }
    return _tableView;
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}



/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
